/**
 * 
 */
package org.wuzhou.lvyou.activity;

import org.wuzhou.lvyou.base.BaseActivity;
import org.wuzhou.lvyou.map.WebMapActivity;
import org.wuzhou.lvyou.view.MainView;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;

/**
 * 主程序Activity
 * 
 * @author Administrator
 */
public class MainActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		initView();
	}

	private void initView() {
		initEV();
		MainView view = new MainView(this);
		setContentView(view);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {// 返回键用户确认是否返退出
			exitDialog();
		}
		return false;
	}

	public void exitDialog() {
		Dialog dialog = new AlertDialog.Builder(MainActivity.this)
				.setTitle("退出程序？").setMessage("您确定要退出程序吗？")
				.setPositiveButton("确定", new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						MainActivity.this.finish();// 结束应用
					}
				})
				.setNegativeButton("取消", new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {

					}
				}).create();// 创建一个对话框
		dialog.show();// 显示对话框
	}

}
